//
//  GEdwardInfoController.m
//  GDHEdwardLive
//
//  Created by 高得华 on 2017/6/18.
//  Copyright © 2017年 高得华. All rights reserved.
//

#import "GEdwardInfoController.h"

@implementation GEdwardInfoController

////单例创建管理者
static GEdwardInfoController * instance = nil;//不能让外部访问，同时放在静态块中的

///创建单例
+ (GEdwardInfoController *)sharedInstance {
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        instance = [[super allocWithZone: NULL] init] ;
    });
    return instance;
}

+(id) allocWithZone:(struct _NSZone *)zone {
    return [GEdwardInfoController sharedInstance] ;
}

- (id) copyWithZone:(struct _NSZone *)zone {
    return [GEdwardInfoController sharedInstance] ;
}

- (instancetype)init {
    if ([super init]) {
        NSDictionary * returnData = [[NSBundle mainBundle] infoDictionary];
        self.CFBundleDisplayName        = returnData[@"CFBundleDisplayName"];
        self.CFBundleShortVersionString = returnData[@"CFBundleShortVersionString"];
        self.CFBundleVersion            = returnData[@"CFBundleVersion"];
        self.CFBundleIdentifier         = returnData[@"CFBundleIdentifier"];
        self.CFBundleName               = returnData[@"CFBundleName"];
        self.UILaunchImages             = returnData[@"UILaunchImages"];
        self.CFBundleIcons              = returnData[@"CFBundleIcons"];

        ///APP中 真实的APP名称数据
        NSString * InfoPlist = [[NSBundle mainBundle] pathForResource:@"InfoPlist.strings" ofType:nil];
        NSDictionary * dictInfoPlist = [NSDictionary dictionaryWithContentsOfURL:[NSURL fileURLWithPath:InfoPlist]];
        NSString * displayName = dictInfoPlist[@"CFBundleDisplayName"];
        if (displayName.length > 0) {
            self.CFBundleDisplayName = displayName;
        }
        
        if (self.CFBundleDisplayName == nil || self.CFBundleDisplayName.length <= 0) {
            self.CFBundleDisplayName = @"APP相册";
        }
    }
    return self;
}

@end
